package com.example.qingyiapp.ui.activity.fragment.fragment_FindUI.adapter;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.example.qingyiapp.R;
import com.example.qingyiapp.service.entify.FindSynamicBean;
import com.example.qingyiapp.service.entify.FindWaitYouBean;

import java.util.ArrayList;

/**
 * Creadted by Met·Wang on 2019/9/18 14:36
 * Describe: NullPointerException Write
 */
public class FindSquareDynamicRecyclerAdapter extends RecyclerView.Adapter<FindSquareDynamicRecyclerAdapter.VHolder> {


    ArrayList<FindSynamicBean.DataBean> list;
    Context context;

    public FindSquareDynamicRecyclerAdapter(ArrayList<FindSynamicBean.DataBean> list, Context context) {
        this.list = list;
        this.context = context;
    }


    @NonNull
    @Override
    public VHolder onCreateViewHolder(@NonNull ViewGroup viewGroup, int i) {
        View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R.layout.fragment_find_square_dynamic_item, null);

        return new VHolder(inflate);
    }

    @Override
    public void onBindViewHolder(@NonNull VHolder vHolder, int i) {

        FindSynamicBean.DataBean dataBean = list.get(i);



        Glide.with(context).load(dataBean.getUser().getUsercover()+"").apply(RequestOptions.circleCropTransform()).into(vHolder.icon);
        vHolder.userName.setText(dataBean.getUser().getName()+"");

        String time = dataBean.getTime();
        String[] s = time.split(" ");
        vHolder.time.setText(s[0]+"");
        vHolder.title.setText(dataBean.getTitle()+"");
        vHolder.content2.setText(Html.fromHtml(dataBean.getSummary()+""));


    }



    @Override
    public int getItemCount() {
        return list.size();
    }

    class VHolder extends RecyclerView.ViewHolder{

        ImageView icon;
        TextView title,userName,content2,time;





        public VHolder(@NonNull View itemView) {
            super(itemView);
            icon=itemView.findViewById(R.id.find_square_waityou_item_Icon);
            title=itemView.findViewById(R.id.find_square_waityou_item_title);
            content2=itemView.findViewById(R.id.find_square_waityou_item_content2);
            userName=itemView.findViewById(R.id.find_square_waityou_item_userName);
            time=itemView.findViewById(R.id.find_square_waityou_item_time);

        }
    }

}
